<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <meta http-equiv="content-type" content="text/html; charset=utf-8" />
    <title>添加分期购订单</title>
    <link href="${base}/resource/admin/css/common.css" rel="stylesheet" type="text/css" />
    <script type="text/javascript" src="${base}/resource/admin/js/jquery.js"></script>
    <script type="text/javascript" src="/resource/admin/js/jquery.tools.js"></script>
    <script type="text/javascript" src="${base}/resource/admin/js/jquery.validate.js"></script>
    <script type="text/javascript" src="${base}/resource/admin/editor/kindeditor.js"></script>
    <script type="text/javascript" src="${base}/resource/admin/js/common.js"></script>
    <script type="text/javascript" src="${base}/resource/admin/js/input.js"></script>
    <script type="text/javascript">
        $().ready(function() {
            var $inputForm = $("#inputForm");
             [@flash_message /]
            var $browserButton = $("#browserButton");
            $browserButton.browser();
        });
    </script>
</head>
<body>
<div class="path">
    <a href="${base}/common/index">首页</a> &raquo;编辑文章
</div>
<form id="inputForm" action="update" method="post" class="required-form" onsubmit="return validateForm(this)">
    <input type="hidden" name="id" value="${entity.id}"/>
    <ul id="tab" class="tab">
        <li>
            <input type="button" value="基础信息" />
        </li>
        <li>
            <input type="button" value="工作信息" />
        </li>
        <li>
            <input type="button" value="联系人信息" />
        </li>
        <li>
            <input type="button" value="贷款信息" />
        </li>
        <li>
            <input type="button" value="图片" />
        </li>
    </ul>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>SN(平台)
            </th>
            <td>
                <input type="text" name="sn" class="text required" readonly="readonly" maxlength="100" value="${entity.sn}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>SN(银行)
            </th>
            <td>
                <input type="text" name="bankSn" class="text" readonly="readonly" maxlength="100" value="${entity.bankSn}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>姓名
            </th>
            <td>
                <input type="text" name="name" class="text required" maxlength="100" value="${entity.name}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>身份证
            </th>
            <td>
                <input type="text" name="cardNo" class="text required isIdCardNo" value="${entity.cardNo}" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>(起始)身份证有效期
            </th>
            <td>
                <input type="text"  name="cardStartDate" value="${entity.cardStartDate?string("yyyy-MM-dd")}" class="text Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'});" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>(截止)身份证有效期
            </th>
            <td>
                <input type="text"  name="cardEndDate" value="${entity.cardEndDate?string("yyyy-MM-dd")}" class="text Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'});" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>性别:
            </th>
            <td>
                <select name="sex" class="text required">
                    <option value="0" [#if entity.sex=0]selected='selected'[/#if]>男</option>
                    <option value="1" [#if entity.sex=1]selected='selected'[/#if]>女</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>出生日期
            </th>
            <td>
                <input type="text"  name="birthDate"  value="${entity.cardEndDate?string("yyyy-MM-dd")}"  class="text Wdate" onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'});" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>婚姻状态:
            </th>
            <td>
                <select name="marry" class="text required">
                    <option value="0" [#if entity.marry=0]selected='selected'[/#if]>已婚</option>
                    <option value="1" [#if entity.marry=1]selected='selected'[/#if]>未婚</option>
                    <option value="2" [#if entity.marry=2]selected='selected'[/#if]>其他</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>教育程度:
            </th>
            <td>
                <select name="eduLevel" class="text required">
                    <option value="0" [#if entity.eduLevel=0]selected='selected'[/#if]>高中及以下</option>
                    <option value="1" [#if entity.eduLevel=1]selected='selected'[/#if]>专科</option>
                    <option value="2" [#if entity.eduLevel=2]selected='selected'[/#if]>本科</option>
                    <option value="3" [#if entity.eduLevel=3]selected='selected'[/#if]>硕士及以上</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>居住地址
            </th>
            <td>
                <input type="text" name="address" class="text required" value="${entity.address}"  style="width: 350px;"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>户籍地址
            </th>
            <td>
                <input type="text" name="censusAddress" class="text required" value="${entity.censusAddress}"  style="width: 350px;" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>户籍邮编
            </th>
            <td>
                <input type="text" name="censusNo" value="${entity.censusNo}" class="text required" length="6" />
            </td>
        </tr>
        <tr>
            <th>
                邮箱
            </th>
            <td>
                <input type="text" name="email" class="text email" value="${entity.email}" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>手机号码
            </th>
            <td>
                <input type="text" name="phone" class="text required" value="${entity.phone}" length="11"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>手机号码(备用)
            </th>
            <td>
                <input type="text" name="phoneTwo" class="text required"  value="${entity.phoneTwo}" length="11"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>是否提交审批:
            </th>
            <td>
                <select name="submitStatus" class="text required">
                    <option value="0" [#if entity.submitStatus=0]selected='selected'[/#if]>不提交</option>
                    <option value="1" [#if entity.submitStatus=1]selected='selected'[/#if]>提交</option>
                </select>
            </td>
        </tr>
    </table>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>工作单位名称
            </th>
            <td>
                <input type="text" name="workUnitName" class="text required" value="${entity.workUnitName}" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>职业:
            </th>
            <td>
                <select name="career" class="text required">
                    <option value="0" [#if entity.career=0]selected='selected'[/#if]>政府及事业职员</option>
                    <option value="1" [#if entity.career=1]selected='selected'[/#if]>企业职员</option>
                    <option value="2" [#if entity.career=2]selected='selected'[/#if]>私营业主</option>
                    <option value="3" [#if entity.career=3]selected='selected'[/#if]>专业技术人员</option>
                    <option value="4" [#if entity.career=4]selected='selected'[/#if]>务农人员</option>
                    <option value="5" [#if entity.career=5]selected='selected'[/#if]>学生</option>
                    <option value="6" [#if entity.career=6]selected='selected'[/#if]>自由职业</option>
                    <option value="7" [#if entity.career=7]selected='selected'[/#if]>其他</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位规模:
            </th>
            <td>
                <select name="unitSize" class="text required">
                    <option value="0" [#if entity.unitSize=0]selected='selected'[/#if]>10人以下</option>
                    <option value="1" [#if entity.unitSize=1]selected='selected'[/#if]>10-100人</option>
                    <option value="2" [#if entity.unitSize=2]selected='selected'[/#if]>100人以上</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>本单位工作年限
            </th>
            <td>
                <input type="text" name="currentUnitWorkYear" class="text required" value="${entity.currentUnitWorkYear}" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>总工作年限
            </th>
            <td>
                <input type="text" name="totalWorkYear" class="text required" value="${entity.totalWorkYear}" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>职位:
            </th>
            <td>
                <select name="jobPost" class="text required">
                    <option value="0" [#if entity.jobPost=0]selected='selected'[/#if]>高层管理</option>
                    <option value="1" [#if entity.jobPost=1]selected='selected'[/#if]>中层管理</option>
                    <option value="2" [#if entity.jobPost=2]selected='selected'[/#if]>一般管理</option>
                    <option value="3" [#if entity.jobPost=3]selected='selected'[/#if]>普通职员</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>任职部门
            </th>
            <td>
                <input type="text" name="jobDepartment" class="text required" maxlength="100" value="${entity.jobDepartment}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位地址
            </th>
            <td>
                <input type="text" name="unitAddress"  class="text required" value="${entity.unitAddress}"  style="width: 350px;"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位邮编
            </th>
            <td>
                <input type="text" name="unitPostNo" class="text required" value="${entity.unitPostNo}" length="6" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位区号
            </th>
            <td>
                <input type="text" name="unitAreaCode" class="text required" value="${entity.unitAreaCode}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>单位电话
            </th>
            <td>
                <input type="text" name="unitPhone" class="text required" value="${entity.unitPhone}"/>
            </td>
        </tr>
    </table>
    <table class="input tabContent">

        <tr>
            <th>
                <span class="requiredField">*</span>关系:
            </th>
            <td>
                <select name="contactRelation" class="text required">
                    <option value="0" [#if entity.contactRelation=0]selected='selected'[/#if] >父母</option>
                    <option value="1" [#if entity.contactRelation=1]selected='selected'[/#if]>配偶</option>
                    <option value="2" [#if entity.contactRelation=2]selected='selected'[/#if]>子女</option>
                    <option value="3" [#if entity.contactRelation=3]selected='selected'[/#if]>兄弟姐妹</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>姓名
            </th>
            <td>
                <input type="text" name="contactName" class="text" maxlength="100" value="${entity.contactName}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>手机
            </th>
            <td>
                <input type="text" name="contactMobile" class="text" length="11" value="${entity.contactMobile}"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>工作单位
            </th>
            <td>
                <input type="text" name="contactUnit" class="text" length="11" value="${entity.contactUnit}"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>地址
            </th>
            <td>
                <input type="text" name="contactAddress" class="text" maxlength="100" value="${entity.contactAddress}"/>
            </td>
        </tr>
        <tr>
            <td colspan="2">&nbsp;</td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>关系:
            </th>
            <td>
                <select name="contactRelationTwo" class="text required">
                    <option value="0" [#if entity.contactRelationTwo=0]selected='selected'[/#if] >亲属</option>
                    <option value="1" [#if entity.contactRelationTwo=1]selected='selected'[/#if] >同事</option>
                    <option value="2" [#if entity.contactRelationTwo=2]selected='selected'[/#if] >同学</option>
                    <option value="3" [#if entity.contactRelationTwo=3]selected='selected'[/#if] >朋友</option>
                    <option value="4" [#if entity.contactRelationTwo=4]selected='selected'[/#if] >其他</option>
                </select>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>姓名
            </th>
            <td>
                <input type="text" name="contactNameTwo" class="text" maxlength="100" value="${entity.contactNameTwo}"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>手机
            </th>
            <td>
                <input type="text" name="contactMobileTwo" class="text" length="11" value="${entity.contactMobileTwo}"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>工作单位
            </th>
            <td>
                <input type="text" name="contactUnitTwo" class="text" maxlength="11"  value="${entity.contactUnitTwo}"/>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>地址
            </th>
            <td>
                <input type="text" name="contactAddressTwo" class="text" maxlength="100" value="${entity.contactAddressTwo}"/>
            </td>
        </tr>

    </table>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>贷款用途:
            </th>
            <td>
                <select name="loanUse" class="text required">
                    <option value="0" [#if entity.loanUse=0]selected='selected'[/#if]>教育</option>
                    <option value="1" [#if entity.loanUse=1]selected='selected'[/#if]>旅游</option>
                    <option value="2" [#if entity.loanUse=2]selected='selected'[/#if]>消费</option>
                    <option value="3" [#if entity.loanUse=3]selected='selected'[/#if]>其他</option>
                </select>
            </td>
        </tr>
        <tr [#if entity.loanUse!=3]style="display: none" [/#if]>
            <th>
                贷款说明
            </th>
            <td>
                <input type="text" name="loanUseInfo" class="text" value="${entity.loanUseInfo}" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>商品金额（元）
            </th>
            <td>
                <input type="text" name="loanAmount" class="text" value="${entity.loanAmount}" maxlength="100" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>还款周期:
            </th>
            <td>
                <select name="loadMonth" class="text required">
                    <option value="12" [#if entity.loadMonth=12]selected='selected'[/#if]>12</option>
                    <option value="18" [#if entity.loadMonth=18]selected='selected'[/#if]>18</option>
                    <option value="24" [#if entity.loadMonth=24]selected='selected'[/#if]>24</option>
                 </select>
            </td>
        </tr>
        <tr>
            <th>

            </th>
            <td>
                <span style="color: #cc0000" id="loanTip">&nbsp;</span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>还款金额（元）
            </th>
            <td>
                <input type="text" name="loanTotal"  class="text number" maxlength="100" value="${entity.loanTotal}" />
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>每月还款（元）
            </th>
            <td>
                <input type="text" name="loanMonPay" readonly="readonly" class="text number" maxlength="100" value="${entity.loanMonPay}" />
            </td>
        </tr>
    </table>
    <table class="input tabContent">
        <tr>
            <th>
                <span class="requiredField">*</span>身份证(正)
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image1" class="text required" value="${entity.image1}" maxlength="200">
						<input type="button" id="image1Button" class="button" value="选择文件">
                        <a href="${entity.image1}" target="_blank">预览</a>
                </span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>身份证(反)
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image2" class="text required"  value="${entity.image2}"  maxlength="200">
						<input type="button" id="image2Button" class="button" value="选择文件">
                        <a href="${entity.image2}" target="_blank">预览</a>
                </span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>贷款申请书(第一联)
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image3" class="text required"  value="${entity.image3}"  maxlength="200">
						<input type="button" id="image3Button" class="button" value="选择文件">
                        <a href="${entity.image3}" target="_blank">预览</a>
                </span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>风险告知书
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image4" class="text required"  value="${entity.image4}"  maxlength="200">
						<input type="button" id="image4Button" class="button" value="选择文件">
                        <a href="${entity.image4}" target="_blank">预览</a>
					</span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>亲签照片
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image5" class="text required"  value="${entity.image5}"  maxlength="200">
						<input type="button" id="image5Button" class="button" value="选择文件">
                        <a href="${entity.image5}" target="_blank">预览</a>
                </span>
            </td>
        </tr>
        <tr>
            <th>
                <span class="requiredField">*</span>工作/学生证明
            </th>
            <td>
                <span class="fieldSet">
						<input type="text"  name="image6" class="text required"  value="${entity.image6}"  maxlength="200">
						<input type="button" id="image6Button" class="button" value="选择文件">
                        <a href="${entity.image6}" target="_blank">预览</a>
					</span>
            </td>
        </tr>
    </table>
    <table class="input">
        <tr>
            <th>
                &nbsp;
            </th>
            <td>
                <input type="submit" class="button" value="提交" />
                <input type="button" class="button" value="返回" onclick="location.href='list'" />
            </td>
        </tr>
    </table>

</form>
<script type="text/javascript">
    $(function(){
        $("select[name='loanUse']").change(function(){
            var opt=$(this).find("option:selected").val();
            if(opt==3){
                $("#loanUseInfoTr").show();
            }else{
                $("#loanUseInfoTr").hide();
            }
        });

        /** 正推算 */
        $("input[name='loanAmount'],select[name='loadMonth']").change(function(){
            var amount=$("input[name='loanAmount']").val();
            var mon=$("select[name='loadMonth']").find("option:selected").val();
            var total;
            var monPay;
            if(mon==12){
                total=amount*1.1;
                monPay=total/12;
            }
            if(mon==18){
                total=amount*1.14;
                monPay=total/18;
            }
            if(mon==24){
                total=amount*1.17;
                monPay=total/24;
            }
            //parseInt
            var text="总共需要偿还： ["+total+"]元,每月偿还: ["+Math.round(monPay)+"]";
            //alert(text);
            $("#loanTip").html(text);
            $("input[name='loanTotal']").val(total);
            $("input[name='loanMonPay']").val(Math.round(monPay));
        });

        /** 反推算 */
        $("input[name='loanTotal']").change(function(){
            var total=$("input[name='loanTotal']").val();
            var mon=$("select[name='loadMonth']").find("option:selected").val();
            var monPay;
            var account;
            if(mon==12){
                monPay=total/12;
                account=total/1.1
            }
            if(mon==18){
                monPay=total/18;
                account=total/1.14
            }
            if(mon==24){
                monPay=total/24;
                account=total/1.17
            }
            //parseInt
            var text="总共需要偿还： ["+total+"]元,每月偿还: ["+Math.round(monPay)+"]";
            //alert(text);
            $("#loanTip").html(text);
            $("input[name='loanAmount']").val(Math.round(account));
            $("input[name='loanTotal']").val(total);
            $("input[name='loanMonPay']").val(Math.round(monPay));
        });

    });
</script>
</body>
</html>